import java.util.Iterator;
import java.util.function.Consumer;

/**
 * @projectName: com.xiayuanxing.designPattern
 * @className: ComputerCollegeIterator
 * @author: xiayuanxing
 * @description: TODO
 * @date: 2022/1/7 11:30
 * @version: 1.0
 */
public class ComputerCollegeIterator implements Iterator {


    /** 这里我们需要Department 是以怎样的方式存放=>数组 */
    Department[] departments;
    //遍历的位置
    int position = 0;

    /** 构造器 */
    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    /**判断是否还有下一个元素*/
    public boolean hasNext() {
        if (position >= departments.length || departments[position] == null){
            return false;
        }else {
            return true;
        }
    }

    /**下一个*/
    public Object next() {
        Department department = departments[position];
        position+=1;
        return department;
    }

    /** 删除的方法 默认空实现 */
    public void remove() {

    }
}
